package com.jf.docsify.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;
import java.io.IOException;

public class IOCloseUtil {

    private final static Logger logger = LoggerFactory.getLogger(IOCloseUtil.class);

    /**
     * IO流关闭工具类
     */
    public static void close(Closeable... io) {
        for (Closeable temp : io) {
            try {
                if (null != temp) {
                    temp.close();
                }
            } catch (IOException e) {
                logger.error("关闭流异常", e);
            }
        }
    }

    public static <T extends Closeable> void closeAll(T... io) {
        for (Closeable temp : io) {
            try {
                if (null != temp) {
                    temp.close();
                }
            } catch (IOException e) {
                logger.error("关闭流异常", e);
            }
        }

    }
}
